]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st-shadows: Use a template material when creating shadows
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 11 Sep 2010 21:54:27 +0000 (23:54 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 13 Sep 2010 16:11:03 +0000 (18:11 +0200)
To avoid recompiling shadows each time a new shadow is created,
use a copy of a static template material.

See http://bugzilla.clutter-project.org/show_bug.cgi?id=2280#c5.

https://bugzilla.gnome.org/show_bug.cgi?id=629383

src/st/st-private.c

index 237635278d68d7f99e7314a3ac06310d23021d6e..264ed727e207b7cb3175fd3b1caadcd5c6627982 100644 (file)
@@ -364,6 +364,8 @@ CoglHandle
 _st_create_shadow_material (StShadow   *shadow_spec,
                             CoglHandle  src_texture)
 {
+  static CoglHandle shadow_material_template = COGL_INVALID_HANDLE;
+
   CoglHandle  material;
   CoglHandle  texture;
   guchar     *pixels_in, *pixels_out;
@@ -483,17 +485,21 @@ _st_create_shadow_material (StShadow   *shadow_spec,
   g_free (pixels_in);
   g_free (pixels_out);
 
-  material = cogl_material_new ();
-
-  cogl_material_set_layer (material, 0, texture);
+  if (G_UNLIKELY (shadow_material_template == COGL_INVALID_HANDLE))
+    {
+      shadow_material_template = cogl_material_new ();
+
+      /* We set up the material to blend the shadow texture with the combine
+       * constant, but defer setting the latter until painting, so that we can
+       * take the actor's overall opacity into account. */
+      cogl_material_set_layer_combine (shadow_material_template, 0,
+                                       "RGBA = MODULATE (CONSTANT, TEXTURE[A])",
+                                       NULL);
+    }
 
-  /* We set up the material to blend the shadow texture with the combine
-   * constant, but defer setting the latter until painting, so that we can
-   * take the actor's overall opacity into account. */
-  cogl_material_set_layer_combine (material, 0,
-                                   "RGBA = MODULATE (CONSTANT, TEXTURE[A])",
-                                   NULL);
+  material = cogl_material_copy (shadow_material_template);
 
+  cogl_material_set_layer (material, 0, texture);
 
   cogl_handle_unref (texture);